//
//  FilterAttr_HeaderV.swift
//  MikerShop
//
//  Created by eme on 2017/1/4.
//  Copyright © 2017年 eme. All rights reserved.
//

/*
 owner:cy
 update:2016年12月15日16:41:41
 */
import UIKit
import Kingfisher
import RxSwift
import RickonCore

class FilterAttr_HeaderV: UITableViewCell {
    //属性名称
    @IBOutlet weak var paname_Lb: UILabel!
    ///选中图片
    @IBOutlet weak var state_ImgV: UIImageView!
    /// 已选中的属性值
    @IBOutlet weak var pavalues_Lb: UILabel!
    // 展开
    @IBOutlet weak var separate_Line_V: UIView!
    @IBOutlet weak var spread_Btn: UIButton!
    private let disposeBag = DisposeBag()
    var didSpreadBtn_Closure:((Void) ->Void)?
    var item :PalistModel?{
        didSet{
            if let item = self.item {
                self.paname_Lb.text = item.paname
                self.pavalues_Lb.text = item.showSubStr
                
            }
        }
    }
    func updateSpeadState(_ isSpreaded:Bool) -> Void {
        if isSpreaded {
            self.state_ImgV.image = UIImage(named: "filter-attr-spreaded", in: RobbCore.bundle, compatibleWith: nil)
        }else{
            self.state_ImgV.image = UIImage(named: "filter-attr-unspreaded", in: RobbCore.bundle, compatibleWith: nil)
        }
    }
 
    
    override func awakeFromNib() {
        self.separate_Line_V.backgroundColor = Theme.v.separate_Line
        self.spread_Btn
            .rx.tap
            .subscribe(onNext: { [unowned self] ( _ ) in
                if let item = self.item{
                    item.isSpreaded = !item.isSpreaded
                }
                if let didSpreadBtn_Closure = self.didSpreadBtn_Closure{
                    didSpreadBtn_Closure()
                }
            })
            .disposed(by: disposeBag)
     
    }
}
